//
//  MYGAcademicDetailTitleCell.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/5/31.
//

import UIKit
import QMUIKit

class MYGAcademicDetailTitleCell: UITableViewCell {
    
    var model:MYGAcademicDetailCellModel?{
        didSet{
            guard let item = model else{return}
            nameLabel.text = item.name
            let name = item.models.joined(separator: ",")
            let nameStr = name.replacingOccurrences(of: ",", with: "\n")
            let str = nameStr.replacingOccurrences(of: "/", with: "")
            contentLabel.text = str.replacingOccurrences(of: "()", with: "")
        }
    }
    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .clear
        contentView.addSubview(backView)
        backView.addSubview(nameLabel)
        backView.addSubview(contentLabel)
        backView.addSubview(line)
        backView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(20)
            make.top.bottom.equalToSuperview()
        }
        
        nameLabel.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.right.left.equalToSuperview().inset(20)
            make.height.equalTo(20)
        }
        
        contentLabel.snp.makeConstraints { make in
            make.left.right.equalTo(nameLabel)
            make.top.equalTo(nameLabel.snp.bottom)
            make.bottom.equalToSuperview().inset(0.5)
        }
        
        line.snp.makeConstraints { make in
            make.left.right.equalTo(nameLabel)
            make.height.equalTo(0.5)
            make.bottom.equalToSuperview()
        }
        
        backView.addBordorLine(top: false, right: true, bottom: false, left: true, color: UIColor.init(hexString: "f6f6f6"), width: 2)
    }
    
    private lazy var backView:UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    private lazy var nameLabel: QMUILabel = {
        let label = QMUILabel()
        label.font = .regular(12)
        label.textColor = .rgba(51, 51, 51, 1)
        return label
    }()
    
    private lazy var contentLabel: QMUILabel = {
        let label = QMUILabel()
        label.font = .regular(12)
        label.textColor = .rgba(51, 51, 51, 1)
        label.numberOfLines = 0
        return label
    }()
    
    private lazy var line:UIView = {
        let line = UIView()
        line.backgroundColor = .rgba(240, 240, 240, 1)
        return line
    }()
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.backgroundColor = .white
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

  
    
}



